package biz.noip.strategy.players.view;

import org.andengine.entity.IEntity;
import org.andengine.entity.modifier.IEntityModifier.IEntityModifierListener;
import org.andengine.entity.modifier.MoveModifier;
import org.andengine.entity.text.Text;
import org.andengine.util.modifier.IModifier;
import org.andengine.util.modifier.ease.EaseSineIn;

import android.opengl.GLES20;
import biz.noip.strategy.mediator.MediatorGame;
import biz.noip.strategy.scenes.GameScene;
import biz.noip.strategy.util.ZIndex;

public class DamageView extends TextView{
 
	public DamageView(GameScene scene) {
		super(scene);
	}

	public Text show(float x, float y){
		final Text text = getText(x, y);
		System.out.println("TEXT: " + text.getText());
		text.setBlendFunction(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
		text.setZIndex(ZIndex.DAMAGE_VIEW.ordinal());
		scene.attachChild(text);
		text.registerEntityModifier(new MoveModifier(1f, x, x, y, (y - 30),
				new IEntityModifierListener() {

			public void onModifierStarted(IModifier<IEntity> arg0,
					IEntity arg1) {
			}

			public void onModifierFinished(IModifier<IEntity> arg0,
					IEntity arg1) {
				MediatorGame.getInstance().deleteChild(text, scene);
			}
		}, EaseSineIn.getInstance()));
		return text;
	}
}
